package org.aplombh.java.interview.test._231029;

import java.util.Scanner;

public class _1汽水瓶 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        while (n != 0) {
            System.out.println(calc(n));
            n = in.nextInt();
        }
    }

    private static int calc(int n) {
        int sum = 0;
        while (n >= 3) {
            sum += n / 3;
            n = n / 3 + n % 3;
        }
        if (n == 2)
            sum++;
        return sum;
    }
}
